﻿// ParseLib - An open source library for natural language processing.
// Copyright (C) Kais Dukes, 2012. E-mail: kais@kaisdukes.com
// http://parselib.org

using System.Windows.Markup;

namespace ParseLib.Corpora
{
    [ContentProperty("BaseCorpus")]
    public class CorpusSample : Corpus
    {
        public override TextualUnit this[int index]
        {
            get { return BaseCorpus[index]; }
        }

        public Corpus BaseCorpus { get; set; }

        public int WordCount { get; set; }

        public override void Load()
        {
            BaseCorpus.Load();

            var tokenCount = 0;
            foreach (var textualUnit in BaseCorpus)
            {
                TextualUnitCount++;
                tokenCount += textualUnit.TokenCount;
                if (tokenCount >= WordCount)
                {
                    return;
                }
            }
        }
    }
}
